package cn.lili.modules.promotion.mapper;

import cn.lili.modules.promotion.entity.dos.GreenCount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.swagger.annotations.ApiModelProperty;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author xiangqian
 * @version 1.0
 * @data 2023/12/18 14:14
 */
public interface GreenCountMapper extends BaseMapper<GreenCount> {

    @ApiModelProperty("查询贡献值总量")
    @Select("select IFNULL(sum(umber),0) from li_green_count")
    BigDecimal getContributionAllValue();

    @ApiModelProperty("根据用户ID查询贡献值总量")
    @Select("select IFNULL(sum(umber),0) from li_green_count where user_id = #{userId}")
    BigDecimal getContributionAllValueByUserId(@Param("userId")String userId);

    @ApiModelProperty("查询所有用户贡献值总量")
    @Select("select * from li_green_count where umber >0")
    List<GreenCount> getContributionAllValueAll();
}
